package board;
import flixel.FlxObject;
import flixel.FlxSprite;
import flixel.group.FlxGroup;
import flixel.text.FlxText;
import flixel.util.FlxRandom;


/*enum TipoDeCasillero {
	Verde;
	Rojo;
	SinEfecto;
	MultX2;
	MultX3;
	DivideX2;
	Carcel;
}*/
class Casillero extends FlxGroup
{
	public var _tipo: String = "SinEfecto";
	private var _posicion:Int = 0;
	var backgroundSprite:FlxSprite;
	var text:FlxText;
	public var xPos:Int;
	public var yPos:Int;
	
	/**
	 * Tipo de este casillero.
	 */
	public var tipo(get, set):String;
	
	function get_tipo() {
		return _tipo;
	}

	function set_tipo(x) {
		return this._tipo = x;
	}
	
	/**
	 * Posicion de este casillero en el tablero (de 0 a n).
	 */
	public var posicion(get, set):Int;
	
	function get_posicion() {
		return _posicion;
	}

	function set_posicion(x) {
		return this._posicion = x;
	}
	

	public function new(pos:Int, tipo:String, width:Int = 100, height:Int = 100)
	{
		super();
		// establecer aleatoriamente el tipo de este casillero.
		_tipo = tipo;
		//		_tipo = FlxRandom.getObject(["Verde", "Rojo", "SinEfecto", "MultX2", "MultX3", "DivideX2"] /*Type.allEnums<TipoDeCasillero>(Enum<TipoDeCasillero>)*/);
		_posicion = pos;
		
		backgroundSprite = new FlxSprite();
		switch (_tipo) 
		{
			case "Verde":
				backgroundSprite.loadGraphic("assets/images/casilleroBackground2.png");
				backgroundSprite.color = 0xB3FF80;

			case "Rojo":
				backgroundSprite.loadGraphic("assets/images/casilleroBackground2.png");
				backgroundSprite.color = 0xFF8080;
			case "SinEfecto":
				backgroundSprite.loadGraphic("assets/images/casilleroBackground2.png");
			case "MultX2":
				backgroundSprite.loadGraphic("assets/images/casilleroMultX22.png");
			case "MultX3":
				backgroundSprite.loadGraphic("assets/images/casilleroMultX3.png");
			case "DivideX2":
				backgroundSprite.loadGraphic("assets/images/casilleroDivideX2.png");
			case "Carcel":
				backgroundSprite.loadGraphic("assets/images/casilleroCarcel2.png");
			case "Salida":
				backgroundSprite.loadGraphic("assets/images/casilleroSalida2.png");
			case "Dado":
				backgroundSprite.loadGraphic("assets/images/casilleroDado.png");

			default:
				
		}
		if (0 <= pos && pos <= 6 )
		{
			xPos = 50 + pos * 100;
			yPos = 50;
		}
		else if (7 <= pos && pos <= 9)
		{
			xPos = 650;
			yPos = 50 + 100 * (pos - 6);
		}
		else if (10 <= pos && pos <= 15)
		{
			xPos = 650 - 100 * (pos - 10);
			yPos = 450;
		}
		else
		{
			xPos = 50;
			yPos = 450 - 100 * (pos - 16);
		}
		backgroundSprite.setPosition(xPos, yPos);
		add(backgroundSprite);		
	}
	
	
	
	override function update()
	{
		super.update();
		
		
	}
	
}



















